package com.ll.module_translate.room

import androidx.room.*
import com.ll.module_translate.entity.TransResult
import kotlinx.coroutines.flow.Flow

/**
 * @Author: ll
 * @CreateTime: 2021/11/01 16:54
 */
@Dao
interface TransDao {
    @Insert(onConflict = OnConflictStrategy.REPLACE)
    fun insert(transResult: TransResult)

    @Update
    fun update(transResult: TransResult)

    @Query("select * from transresult")
    fun queryHistoryList():Flow<MutableList<TransResult>>

    @Query("select * from transresult ORDER BY id DESC")
    fun queryHistoryListDesc():Flow<MutableList<TransResult>>

    @Query("delete from transresult")
    fun deleteData()

    @Query("delete from transresult WHERE id=:id")
    fun deleteOneData(id:Int)
    @Query("select * from transresult where `like` = 1")
    fun queryLikeList():Flow<MutableList<TransResult>>

    @Query("select * from transresult where `like` = 1 ORDER BY id DESC")
    fun queryLikeListDesc():Flow<MutableList<TransResult>>

}